package com.example.mysafegarud;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

public class FActivity extends AppCompatActivity {

    private ViewPager viewPager;
    private TabLayout tabLayout;
    private List<Fragment> fragmentList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_f);
        initView();
    }

    private void initView() {
        viewPager = findViewById(R.id.viewPage);
        tabLayout = findViewById(R.id.tabLayout);
        fragmentList.add(new Fragment1());
        fragmentList.add(new Fragment2());
        fragmentList.add(new Fragment3());
        fragmentList.add(new Fragment4());
        FragmentAdpters fragmentAdpters = new FragmentAdpters(getSupportFragmentManager(), 1, fragmentList);
        viewPager.setAdapter(fragmentAdpters);
        tabLayout.setupWithViewPager(viewPager);
    }
}
